package com.waitingresult.designpattern.behavioral.strategy.enums;

import lombok.Getter;

/**
 * All right reserved,Designed By WangShuai
 *
 * @author : WangShuai
 * @version : V1.0
 * @ClassName : StrategyEnum
 * @Description :
 * @date : 2022/9/15 21:38
 */
@Getter
public enum StrategyEnum01 {
    One("One",new StrategyOne()),
    Tow("Tow",new StrategyTow());
    private String name;
    private BizStrategy strategy;

    StrategyEnum01(String name, BizStrategy strategy) {
        this.name = name;
        this.strategy = strategy;
    }


    public static BizStrategy getStrategyByName(String name) {
        for (StrategyEnum01 value : StrategyEnum01.values()) {
            if(value.getName().equals(name)){
                return value.getStrategy();
            }
        }
       throw new RuntimeException();
    }
}
